from asyncio.windows_events import NULL
import os
import cv2
import shutil

# list = os.listdir('./test/')
# list = os.listdir('E:\onecloud\tddownload')
list = os.listdir('./')

def see_video(filename):
    cap = cv2.VideoCapture(filename)
    cap.set(cv2.CAP_PROP_POS_FRAMES, 5050)
    # ret, frame = cap.read()
    target_Del = NULL
    while 1:
        ret, frame = cap.read()
        res = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5)
        key = cv2.waitKey(1)
        cv2.imshow('frame', res)
        if key & 0xFF == ord('q') or ret == False:
            print("========next=========")
            cap.release()
            cv2.destroyAllWindows()
            break
        elif key & 0xFF == ord('d'):
            # shutil.rmtree(filename)
            target_Del = filename
            print("删除成功")
            cap.release()
            cv2.destroyAllWindows()
            break
        cv2.imshow('frame', res)
    # os.remove(target_Del)
    # os.rename(filename,"")


for list_sam in list:
    try:
        test = os.listdir(f'./{list_sam}')
        for te in test:
            ls = te.endswith('flv')
            # print(ls)
            if ls:
                print(f"{te}文件是flv")
                # see_video(f"./test/{list_sam}/{te}")
            else:
                print("不是目标文件类型")
    except:
        print("不是文件夹")
